-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
util: deprecate util._extend #4593
Conversation
@@ -967,7 +967,7 @@ exports.connect = function(/* [port, host], options, cb */) { | |||
minDHSize: 1024 | |||
}; | |||
|
|||
options = util._extend(defaults, options || {}); | |||
options = Object.assign(defaults, options || {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Object.assign()
can handle this without the || {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. With one exception, this was mainly a find/replace. I'll go through it once more to clean up this kind of usage.
Although it is not documented, I've seen this used quite a bit in the wild. |
LGTM if the CI is happy. I'm in favor of this change even without the deprecation of |
It's used by I'm +1 to this change, but this requires a deprecation imo. Update: |
+1 to adding a suggested alternative (e.g. |
That's what this PR does. Actual removal would be a while down the road. |
@mscdex I thought about which alternative to recommend but couldn't think of one that didn't involve picking a favourite or relying on Node >= 0.12. I guess |
@rmg I noticed that, but a comment just above mine mentioned removing this without deprecation, that was why I expressed my opinion about that. |
@ChALkeR ah, I see now. 👍 |
My comment didn't mean to remove without deprecation. It meant that I'm in favor of this change even if we don't touch |
@rmg This change would be going into a version of node post-v0.12, so I wouldn't be concerned. v0.12 users would not see this deprecation message. |
Not sure I like the idea of suggesting switching to |
@Qard The way I interpret messages like this is that they only apply for that particular version because the only way you're seeing it is if you're already using a newer node version. To me this is different than the API docs where people may bookmark the shrug |
A well known alternative would be the util-extend package. By the way, this doesn't strictly need to be |
@mscdex Yes, but a module author might try to use util._extend, encounter the deprecation message, and think it's safe to just switch the Object.assign, which is not necessarily the case. I'm not firmly against the message, I just wanted to bring attention to this scenario to think about. |
I think we should be able to expect module authors to know that LGTM |
LGTM |
@silverwind Given how many of popular modules use @rmg Did you test npm? Atm it bundles its deps, and depends on |
@rmg I think its worth breaking into two PRs. Internally changing to Deprecating @Qard Many deprecations, such as exists in favour of access, has a chance of not working on older Node.js. Its a bit touch keeping compat with 0.10, takes care, and the fact that our docs don't mention at which node version a feature was introduced or modified is not helpful. |
Splitting it into two commits in this PR would work too. |
The Object.assign slower than _extend 33%. |
I thought about splitting it into 2 commits but couldn't decide at the time which order made more sense so I punted and combined them. I guess the deprecation makes more sense after removing all usage. I'll split it that way. |
-1 for deprecating this undocumented yet so useful util function |
The ES6 part is actually coincidental, the actual goal is to move toward a more clearly defined API. It was a coin toss between submitting a PR that deprecates it or submitting a PR that documents it. Since I'm not particularly fond of |
I'm -1 on deprecating it as well. |
Hmmm, ok, so at this point we have several LGTM's but also several -1's. I'm going to recommend that we drop this onto the @nodejs/ctc agenda for a quick discussion. |
@jasnell good idea. I'm more than willing to replace this PR with a different PR that adds docs for |
I would vote -1 for adding something like |
We could just replace our internal uses of |
Differences between
|
@domenic Does that include #4593 (comment)? |
@ChALkeR good catch, will update! |
I just read the consensus. I think we can start by replacing all internal usage of |
CTC resolution regarding deprecation of
Someone needs to do that, however. It's not even in the docs so the idea was to doc it and say that it's deprecated and shouldn't be used, "use It's in too heavy usage. See 2016-01-20 minutes that are going in via PR shortly, audio also available. |
@rvagg made a quick PR. |
See the discussion here nodejs#4593 for more details as well as the 2016-01-20 minutes. PR-URL: nodejs#4902 Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: thefourtheye <[email protected]>
doc: document deprecation of util._extend See the discussion here nodejs#4593 for more details as well as the 2016-01-20 minutes.
Didn't someone mention that the perf is worse with |
Closing in favour of #4903 - I'm happy just to have kicked off the conversation :-) Thanks for picking up the slack while I was absent, @benjamingr! |
Mark util._extend as deprecated and replace all internal usage with the
language provided Object.assign.
util._extend is a long standing member of the undocumented and
unofficial public API. It has never been removed because, quite frankly,
it is ridiculously useful and is used extensively throughout node core
itself.
With the addition of support for Object.assign in node, and the use of
other ES6isms, there is now an alternative to maintaining util._extend
and adding it to the API docs.
/cc @sam-github @jasnell